package com.dss.auto_deploy.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.dss.auto_deploy.domain.Server;
import com.dss.auto_deploy.dto.*;
import com.dss.auto_deploy.vo.FolderVo;
import com.dss.auto_deploy.vo.ServerVo;
import com.dss.auto_deploy.vo.SftpDownloadVo;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @description: iserver服务
 * @author: dongshoushan
 * @date:2022-11-23 20:56:05
 */
public interface IServerService extends IService<Server> {
    /**
    * 新增虚拟机服务器
    * @param serverAddDto
    * @return
    */
    int insert(ServerAddDto serverAddDto);

    /**
    * 修改虚拟机服务器
    * @param serverUpdateDto
    * @return
    */
    int update(ServerUpdateDto serverUpdateDto);

    /**
    * 批量删除虚拟机服务器
    * @param ids
    * @return
    */
    void deleteBatch(Long[] ids);

    /**
     * 查询所有文件夹
     * @return
     */
    List<FolderVo> getAllFolder();

    /**
     * 查询所有虚拟机
     * @param ip
     * @return
     */
    List<ServerVo> getAllServer(String ip);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    Server getServerById(Long id);
    Server getServerByIp(String ip);
    Server getServerByRegistryId(Long registryId);
    Server getServerByDockerId(Long dockerId);

    /**
     * 查询虚拟机配置
     * @return
     */
    List<ServerVo> getList();
    List<Server> getAll();

    /**
     * 更新linux信息
     */
    void updateLinuxInfo();

    String getLoclIp();

    SftpDownloadVo downloadForTemp(QueryFileByPathDto dto) throws Exception;

    void saveContentForTemp(SftpDownloadVo dto) throws Exception;

    void download(QueryFileByPathDto dto, HttpServletResponse response) throws InterruptedException, IOException;
    void downloadList(QueryFileByPathDto dto, HttpServletResponse response) throws InterruptedException, IOException;

    /**
     * @param dto dto
     * @description: 添加服务器文件
     * @author: dongshoushan
     * @date:2022-11-23 22:22:24
     */
    void addServerFile(ServerFileAddDto dto);

    /**
     * @param dto dto
     * @description: 删除服务器文件
     * @author: dongshoushan
     * @date:2022-11-23 23:15:21
     */
    void delServerFile(List<ServerFileDelDto>  list);

    /**
     * @param dto dto
     * @description: 重命名名称服务器文件
     * @author: dongshoushan
     * @date:2022-11-24 09:22:11
     */
    void reNameServerFile(ServerFileReNameDto dto);


    /**
     * @param registryId 仓库id
     * @description: 删除旧镜像
     * @author: dongshoushan
     * @date:2022-11-24 14:04:52
     */
    void deleteOldImages(String registryId);

    /**
     * @param ip   知识产权
     * @param path 路径
     * @param file 文件
     * @description: 上传
     * @author: dongshoushan
     * @date:2022-11-24 20:13:23
     */
    void upload(String ip, String path, MultipartFile file);

    /**
     * @param dto dto
     * @description: 检查路径是正确
     * @author: dongshoushan
     * @date:2022-11-24 22:32:10
     */
    Boolean checkPathIsTrue(CheckPathIsTrueDto dto);
}
